home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / BSPRTSCR.C < prev    next >
C/C++ Source or Header  |  1993-09-10  |  5KB  |  164 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    bsprtscr.c
  5. //   Title:    Base library
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //
  24. //    This module contains code to enable and disable <Print Screen> 
  25. //    functionality. It contains an interrupt service routine for interrupt 5.
  26. //    This ISR does not do anything.
  27. //
  28. //
  29. //    I haven't tested it, but the following method can also be used to enable
  30. //    and disable print screens:
  31. //
  32. //      if (turn_on)
  33. //           pokeb(0x0050, 0x0000, 0);
  34. //      else
  35. //            pokeb(0x0050, 0x0000, 1);
  36. //
  37. //
  38. //    The code in this module should be written entirely in C. 
  39. //    Do not use any C++ constructs.
  40. //
  41. //    This module is portable to:
  42. //        DOS 3.X+
  43. //        MS Windows 3.X+
  44. //        OS/2 2.X+
  45. //        OS/2 2.0 PM
  46. //        SCO UNIX.
  47. //
  48. //    The following compilers are supported:
  49. //        MSC 6.0A
  50. //        MSC/C++ 7.0
  51. //        Borland C++ 3.1 for DOS
  52. //        Borland C++ 1.0 for OS/2 2.X
  53. //        SCO UNIX cc
  54. //
  55. //----------------------------------------------------------------------------
  56. //
  57. // The print screen can also be turned off by using these calls:
  58. //
  59. //        if (turn_on)
  60. //              pokeb(0x0050, 0x0000, 0);
  61. //        else
  62. //              pokeb(0x0050, 0x0000, 1);
  63. //
  64. //----------------------------------------------------------------------------
  65. #include <bs.h>
  66. #if OS_DOS && COMPILER_BORLAND
  67.  
  68. //----------------------------------------------------------------------------
  69. //    Globals
  70. //----------------------------------------------------------------------------
  71. static void _interrupt (*oldint5)(void);
  72.  
  73.  
  74. //----------------------------------------------------------------------------
  75. //   Description:    New interrupt handler for INT 5 (print screen)
  76. //    Parameters:
  77. //       Returns:    
  78. //----------------------------------------------------------------------------
  79. void _interrupt new_int_5(void)
  80. {
  81.     // Do nothing!!
  82.     return ;
  83. }
  84.  
  85.  
  86. //----------------------------------------------------------------------------
  87. //   Description:    Re-install previous print screen handler.
  88. //    Parameters:
  89. //       Returns:    
  90. //----------------------------------------------------------------------------
  91. VOID FN_E PrintScreenTerminate(void)
  92. {
  93.     if (oldint5)                                // Uninstall new
  94.         {
  95.         Assert(oldint5 == _dos_getvect(5));
  96.        _dos_setvect(5,oldint5);
  97.         oldint5 = NULL;
  98.         }
  99.     return ;
  100. }
  101. #endif                                            // #if OS_DOS && COMPILER_BORLAND
  102.  
  103.  
  104. //----------------------------------------------------------------------------
  105. //   Description:    Enable and disable print screen.
  106. //    Parameters:    fDisable        If true, print screen is disabled.
  107. //       Returns:    
  108. //----------------------------------------------------------------------------
  109. VOID FN_E PrintScreen(BOOL fDisable)
  110. {
  111. #if OS_DOS && COMPILER_BORLAND
  112.  
  113.     if (fDisable)
  114.         {
  115.         if (oldint5 == NULL)
  116.             {
  117.            oldint5 = _dos_getvect(5);
  118.            _dos_setvect(5,new_int_5);
  119.             BaseExitFunc((PFNEXIT)PrintScreenTerminate, SYS_EXIT_PRIORITY);
  120.             }
  121.         }
  122.     else
  123.         PrintScreenTerminate();
  124. #else
  125.     NOTUSED(fDisable);
  126. #endif
  127.  
  128.     return ;
  129. }
  130.  
  131.  
  132. //----------------------------------------------------------------------------
  133. //   Description:    Run standard test suite
  134. //    Parameters:    sTest        Test to run.
  135. //                                        0        Run all default tests (except).
  136. //       Returns:    TRUE if successful.
  137. //----------------------------------------------------------------------------
  138. #if COMPILE_TEST
  139. BOOL FN PrintScreenTest(SHORT sTest)
  140. {
  141.     NOTUSED(sTest);
  142. #if OS_DOS && COMPILER_BORLAND
  143.  
  144.     KbdFlush();
  145.     PrintScreen(TRUE);
  146.     Output("Print screen is disabled.\nPress any key to continue.\n");
  147.     while (!KbdReady())
  148.         ;
  149.  
  150.     KbdChar();
  151.     PrintScreen(FALSE);
  152.     Output("Print screen is enabled.\n");
  153.  
  154. #else
  155.     Output("This test is only valid under DOS\n");
  156. #endif
  157.     return TRUE;
  158. }
  159. #endif
  160. //----------------------------------------------------------------------------
  161. //------------------------------- End of File --------------------------------
  162. //----------------------------------------------------------------------------
  163.  
  164.